package com.atcc.demo.controller;





import java.io.BufferedReader;
import java.io.InputStreamReader;

import javax.servlet.ServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.atcc.demo.common.CommonResult;
import com.atcc.demo.common.TokenHelper;
import com.atcc.demo.domain.TokenModel;
import com.atcc.demo.domain.UserInfo;
import com.atcc.demo.service.UserInfoService;
import com.atcc.demo.service.UserTokenService;
import com.atcc.demo.util.ResultUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@Api(tags= {"用户登录管理"})
@RequestMapping("/login/user")
public class LoginController {
	
	@Autowired
	UserTokenService userTokenService;
	
	@Autowired
	UserInfoService userInfoService;
        
	@ApiOperation(value="用户登陆验证",notes="用户登陆验证")
	@PostMapping(value="/login")
	public String login(ServletRequest req) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(req.getInputStream()));
			StringBuffer sb = new StringBuffer();
			String s = null;
			if((s = br.readLine())!= null) {
				sb.append(s);
			}
			JSONObject jsonObject = JSONObject.parseObject(sb.toString());
			String data = jsonObject.getString("username");
			String test = jsonObject.getString("password");
			
			return test+data;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
//	@ApiOperation(value="用户退出登录",notes="用户退出登录")
//	@GetMapping(value="/logout")
//	public String logout(@RequestHeader("token") String token
//			) {
//		return "";
//	}
//	
//	@ApiOperation(value="验证token是否失效",notes="验证token是否失效")
//	@GetMapping(value="/verifytoken")
//	public String verify(@RequestHeader("token") String token
//			) {
//		return "";
//	}
//	
//	@ApiOperation(value="根据token来获取tokenmodel",notes="根据token来获取tokenmodel")
//	@GetMapping(value="/get/tokenmodel")
//	public String getTokenModel(@RequestHeader("token") String token
//			){
//		return "";
//	}
}
